﻿using PetaPoco;
using PmSoft;
using PmSoft.Caching;
using System.ComponentModel;
using static Modules.Device.CheckInDeviceConstants;

namespace Modules.Device.Entitys
{
    /// <summary>
    /// 设备下发命令记录
    ///</summary>
    [TableName("checkin_device_command")]
    [Description("考勤设备下发命令记录")]
    [PrimaryKey("id", AutoIncrement = true)]
    [CacheSetting(true, Name = "CheckinDeviceCommand")]
    [Serializable]
    public class CheckinDeviceCommand : IEntity
    {
        /// <summary>
        /// 主键
        ///</summary>
        [Column("id")]
        public int Id { get; set; }

        /// <summary>
        /// 命令名称
        ///</summary>
        [Column("name")]
        public string Name { get; set; }

        /// <summary>
        /// 命令代码
        ///</summary>
        [Column("code")]
        public 考勤机命令 Code { get; set; }

        /// <summary>
        /// 消息id
        ///</summary>
        [Column("message_id")]
        public string MessageId { get; set; }

        /// <summary>
        /// 设备编码
        ///</summary>
        [Column("device_code")]
        public string DeviceCode { get; set; }

        /// <summary>
        /// 返回信息
        ///</summary>
        [Column("result")]
        public string Result { get; set; }

        /// <summary>
        /// 下发时间
        ///</summary>
        [Column("distribute_time")]
        public DateTime? DistributeTime { get; set; }

        /// <summary>
        /// 返回时间
        ///</summary>
        [Column("result_time")]
        public DateTime? ResultTime { get; set; }

        /// <summary>
        /// 是否自动下发
        /// </summary>
        [Column("is_auto")]
        public bool IsAuto { get; set; }

        /// <summary>
        /// 下发命令
        /// </summary>
        [Column("jobs")]
        public string? Jobs { get; set; }

        /// <summary>
        /// 状态 0:待下发 1:已下发 2:已回调
        /// </summary>
        [Column("status")]
        public 命令下发状态 Status { get; set; }

        /// <summary>
        /// 返回消息
        /// </summary>
        [Column("result_msg")]
        public string? ResultMsg { get; set; }

        /// <summary>
        /// 错误重发次数
        /// </summary>
        [Column("try_count")]
        public int? TryCount { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [Column("create_time")]
        public DateTime CreateTime { get; set; }

        #region IEntity 成员

        [Ignore]
        object IEntity.EntityId { get { return Id; } }

        #endregion IEntity 成员
    }
}